package ar.edu.uba.fi.jmit.graphvisualizer.server.mock;

import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.LinkedList;
import java.util.List;

import ar.edu.uba.fi.jmit.graphvisualizer.client.MethodTimeEventService;
import ar.edu.uba.fi.jmit.graphvisualizer.shared.TimeValue;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class MethodTimeEventServiceMock extends RemoteServiceServlet implements MethodTimeEventService {

	private static final long serialVersionUID = -688833664448389549L;

	@Override
	public List<TimeValue> getMonitorData(String application, String monitorName) {
		List<TimeValue> list = new LinkedList<TimeValue>();
		Calendar calendar = new GregorianCalendar();
		calendar.set(Calendar.SECOND, 0);
		for(int i = 0; i < 59; i++) {
			calendar.roll(Calendar.SECOND, true);
			list.add(new TimeValue(calendar.getTime(), new Double(Math.random() * 400).intValue()));
		}
		return list;
	}

	@Override
	public List<TimeValue> getAverageData(String applicationName,
			String monitorName) {
		List<TimeValue> list = new LinkedList<TimeValue>();
		Calendar calendar = new GregorianCalendar();
		calendar.set(Calendar.SECOND, 0);
		for(int i = 0; i < 59; i++) {
			calendar.roll(Calendar.SECOND, true);
			list.add(new TimeValue(calendar.getTime(), new Integer(200 + i % 10)));
		}
		return list;
	}

}
